/*
 **	Bone.h

 Program: glutMOCAPviewer  
 Language: C++
 Date:  Dec 10 2007      
 Version: 0.1   

 **      Created: Nov 23 2007.
 **	
 **	purpose: Store data for one bone of given skeleton 
 */

#ifndef __BONE_H__
#define __BONE_H__

#include <string>
#include <vector>

#include "Vector.h"

using namespace std;

/**
 * This class implements a bone for store data for one bone of given skeleton
 */
class Bone {
public:
    /**
     * Constructor.
     * Default constructor
     */
    Bone() {
    }

    /**
     * Constructor.
     * Constructor passing initial values.
     * @param _id given bone id (unique)
     * @param _name given bone name (unique)
     * @param _direction given bone direction
     * @param _length given bone length
     * @param _axis given bone rotation axis
     * @param _axis_order given bone axis order for rotations
     * @param _bodymass given bone bodymass
     * @param _cofmass given bone cofmass
     * @param _dof given bone degrees of freedom
     * @param _limits given bone limits of each degree of freedom
     * @param _axis_x given bone axis X rotated 
     * @param _axis_y given bone axis Y rotated
     * @param _axis_z given bone axis Z rotated
     */
    Bone(int _id, string _name, Vector3d _direction, double _length, Vector3d _axis, string _axis_order,
			double _bodymass, double _cofmass, string _dof, vector<Vector2d> _limits, Vector3d _axis_x,
			Vector3d _axis_y, Vector3d _axis_z);

    // Getters    
    /**
     * Get the bone segment.
     * @return bone length * bone direction
     */
    inline Vector3d lenXdir() {
        return length * direction;
    }

    /**
     * Get color of bone
     * @return bone color
     */
    inline Vector3d getColor() {
        return color;
    }

    /**
     * Get name of bone
     * @return bone name
     */
    inline string getName() {
        return name;
    }

    /**
     * Get direction of bone
     * @return bone direction
     */
    inline Vector3d getDirection() {
        return direction;
    }
    
    /**
     * Get length of bone
     * @return bone length
     */
    inline double getLength() {
        return length;
    }

    /**
     * Get axis X of bone
     * @return bone axis X
     */
    inline Vector3d getAxis_X() {
        return axis_x;
    }

    /**
     * Get axis Y of bone
     * @return bone axis Y
     */
    inline Vector3d getAxis_Y() {
        return axis_y;
    }

    /**
     * Get axis Z of bone
     * @return bone axis Z
     */
    inline Vector3d getAxis_Z() {
        return axis_z;
    }

    /**
     * Get axis order of bone
     * @return bone axis order
     */
    inline string getAxisOrder() {
        return axis_order;
    }

    /**
     * Get degrees of freedom of bone
     * @return bone degrees of freedom
     */
    inline string getDOF() {
        return dof;
    }

    // Setters
    /**
     * Set direction of bone
     * @param param given new direction
     */
    inline void setDirection(Vector3d param) {
        direction = param;
    }

    /**
     * Set axis X of bone
     * @param param given new axis X
     */
    inline void setAxis_X(Vector3d param) {
        axis_x = param;
    }

    /**
     * Set axis Y of bone
     * @param param given new axis Y
     */
    inline void setAxis_Y(Vector3d param) {
        axis_y = param;
    }

    /**
     * Set axis Z of bone
     * @param param given new axis Z
     */
    inline void setAxis_Z(Vector3d param) {
        axis_z = param;
    }
    
    inline void setAngles(double _alfa, double _beta, double _gama){
    	alfa = _alfa;
    	beta = _beta; 
    	gama = _gama;    	
    }

private:
    int                     id; /**< Bone id (unique). */
    string                  name; /**< Bone name (unique). */
    Vector3d                direction, /**< Bone direction. */
    						or_direction; /**< Original's Bone direction. */;
    double                  length; /**< Bone length. */
    double					alfa, beta, gama; /**< Rotation angles for this bone. */
    Vector3d                //axis, /**< Bone rotation axis. */
                            axis_x, /**< Bone axis X rotated. */
                            axis_y, /**< Bone axis Y rotated. */
                            axis_z; /**< Bone axis Z rotated. */
    string                  axis_order; /**< Bone axis order for rotations. */
    double                  bodymass; /**< Bone bodymass. */
    double                  cofmass; /**< Bone cofmass. */
    string                  dof; /**< Degrees of freedom. */
    vector<Vector2d>        limits; /**< Limits of each degree of freedom. */
    Vector3d                color; /**< Bone color (random). */

};

#endif
